import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';

import { ErrorMessageMode } from '/@/utils/http/axios/types';

enum Api {
  Login = '/login',
  GetUserInfo = '/getInfo',
  GetUserInfoId = '/system/user/',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<LoginResultModel>(
    {
      url: Api.Login,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: getUserInfoById
 */
export function getUserInfo() {
  return defHttp.get<GetUserInfoModel>({
    url: Api.GetUserInfo,
  });
}
/**
 * @description: getUserInfoById
 */
export function getUserInfoById(params: Number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<GetUserInfoModel>(
    {
      url: Api.GetUserInfoId + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
